home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16181 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  58 lines

  1. Path: news.helsinki.fi!not-for-mail
  2. From: marjakan@cc.helsinki.fi (Erkka I Marjakangas)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help: very simple(?) array problem
  5. Date: 10 Apr 1996 00:12:31 +0300
  6. Organization: University of Helsinki
  7. Message-ID: <4kejrv$ml2@kruuna.helsinki.fi>
  8. NNTP-Posting-Host: kruuna.helsinki.fi
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=ISO-8859-1
  11. Content-Transfer-Encoding: 8bit
  12.  
  13. I have tried to get a piece of code to work for couple of hours now and
  14. I don't know any longer what is wrong with it. All seems OK with me, but
  15. still compiler (both GNU-C++ and C++) give an error:
  16. "initializer for scalar variable requires one element".
  17. I'm totally confused.
  18.  
  19. The code looks following...
  20.  
  21. class Object
  22. {
  23. ...
  24.  Object(char **name);
  25. ...
  26. };
  27.  
  28. Object::Object(char **name)
  29. {
  30.  ...
  31. }
  32.  
  33. main()
  34. {
  35.     char **b={"First","Second"};
  36.     Object a(b);
  37. }
  38.  
  39. If I change main() to
  40. {
  41.     Object a({"First","Second"});
  42. }
  43.  
  44. both compilers report "parse error before {" at that line which
  45. contains Object a(...);
  46.  
  47. I simply cannot understand what can be wrong, to me it looks just fine.
  48. Can anyone help?
  49.  
  50. Thanks in advance,
  51. Ede
  52.  
  53. -- 
  54. Erkka Marjakangas, Hietaniemenk14A209,00100 HKI, FINLAND|     To SEE or
  55. marjakan@cc.helsinki.fi    Tel: +358-40-512 06 36       |    not to SEE,
  56. WWW:<A HREF="http://www.helsinki.fi/~marjakan/">Home</A>|    now that is
  57. A2000/A3001/4MB/80MB/A2286[PGP key available at request]|   the question!
  58.